var _that;
var _addCarCallBack, _buyCallBack;
// 添加购物车回调  立即购买回调
function init(target, addCarCallBack, buyCallBack) {
  _that = target,
    _addCarCallBack = addCarCallBack;
  _buyCallBack = buyCallBack;

  _that.setData({
    showbuy: false,
    showBuyCnt: false
  });
}

function showBuyDetail(goodsindex) {
  _that.setData({
    showbuy: true,
    curspec: 0,
    goodsindex: goodsindex
  });

  _that.setData({
    showBuyCnt: true
  })
}

function closeBuyDetail() {
  _that.setData({
    showBuyCnt: false
  })
  setTimeout(() => {
    _that.setData({
      showbuy: false
    })
  }, 300)
}

function addCar() {
  closeBuyDetail();
  _addCarCallBack();
}

function buy() {
  _buyCallBack();
}

function chooseSpec(e) {
  var curspec = e.currentTarget.dataset.specindex;
  _that.setData({
    curspec: curspec
  });
}

module.exports = {
  init: init,
  show: showBuyDetail,
  close: closeBuyDetail,
  addCar: addCar,
  buy: buy,
  chooseSpec: chooseSpec
}





